package com.superteam.zzl.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;

/**
 * Created by Administrator on 2017/1/10.
 */

public class TrendsIv extends ImageView {

    private Paint paint;

    public TrendsIv(Context context) {
        super(context);
        init();
    }

    public TrendsIv(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        paint = new Paint();
        paint.setStrokeWidth(6);
        paint.setColor(Color.parseColor("#ff0000"));
        paint.setStyle(Paint.Style.STROKE);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        LinearLayout parent = (LinearLayout) getParent();
        int childCount = parent.getChildCount();
        canvas.drawCircle(getLeft() + 5, getTop() + 5, 10, paint);
        canvas.drawText(String.valueOf(childCount), getLeft() + 5, getTop() + 5, paint);
    }
}
